package com.xnyzc.lhy.didi.controller.price;

import com.xnyzc.lhy.common.component.didi.DiDiUrlConstant;
import com.xnyzc.lhy.common.entity.DiDiRv;
import com.xnyzc.lhy.common.exception.DiDiException;
import com.xnyzc.lhy.common.penum.EDiDiErrorCode;
import com.xnyzc.lhy.common.util.sign.AttestationTool;
import com.xnyzc.lhy.didi.entity.param.order.BillRulesPriceParam;
import com.xnyzc.lhy.didi.entity.param.order.ForecastPriceParam;
import com.xnyzc.lhy.didi.service.price.PriceCorrelationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 价格相关
 * </p>
 *
 * @author wangshuo
 * @since 2019-09-25
 */
@Slf4j
@RestController
@RequestMapping("oa/didi/price")
public class PriceCorrelationController {

    @Autowired
    private PriceCorrelationService priceCorrelationService;

    /**
     * 预估价格开发版本
     *
     * @param forecastPriceParam
     * @return
     */
    @ApiOperation(value = "预估价格开发", notes = "预估价格开发")
    @PostMapping(value = "/getForecastPriceReal")
    public DiDiRv getForecastPriceReal(@ApiParam(name =
            "forecastPriceParam", value = "预估价格") ForecastPriceParam forecastPriceParam) {
        if (!AttestationTool.getRequestSign(forecastPriceParam, forecastPriceParam.getSign(), DiDiUrlConstant.didiSignReq)) {
            throw DiDiException.create(EDiDiErrorCode.failureOfVerification);
        }
        return priceCorrelationService.getForecastPriceReal(forecastPriceParam);
    }

    /**
     * 计价规则
     *
     * @param billRulesPriceParam
     * @return
     */
    @ApiOperation(value = "计价规则", notes = "计价规则")
    @PostMapping(value = "/getBillRules")
    public DiDiRv getBillRules(@ApiParam(name =
            "forecastPriceParam", value = "计价规则") BillRulesPriceParam billRulesPriceParam) {
        return priceCorrelationService.getBillRules(billRulesPriceParam);
    }

}
